<html>
<body>
<?php
require("config.php");

if($_POST['login'] == "" && $_SESSION['login'] == ""){
?>
If you already registered, you can login: 
<form action=login.php method=POST>
<table>  
<tr><td>Login: </td><td><input type=text name=login value=Login></td></tr>
<tr><td>Password: </td><td><input type=password name=pass value=Password></td></tr>
</table>
<input type=Submit>
</form>
<?php
}else{
  $login = $_POST['login'];
  $pass = $_POST['pass'];
  $pass = md5($pass);
  $query = "SELECT pass FROM $table WHERE name='$login'";
  $result = mysql_query($query);
  $pwd = mysql_result($result,0,"pass");
  if($pwd == $pass){
    $_SESSION['login'] = $login;
    $_SESSION['pass'] = $pass;
    header("Location: user/index.php");
  }else{
    echo "Wrong password!";
  };
};
if($_SESSION['login'] != "" && $_SESSION['pass'] != ""){
  header("Location: user/index.php");
};
mysql_close();
?>
</body>
</html>
